package com.odriver.neulearn.Util;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.odriver.neulearn.Activity.MeunActivity;
import com.odriver.neulearn.Bean.MenuBean;
import com.odriver.neulearn.LoginActivity;
import com.odriver.neulearn.R;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yeruyi on 2016/11/28.
 */

public class TransferUtil {

    private static RequestQueue mQueue;

    /**
     * 获取网络图片
     *
     * @param context   当前context
     * @param PIC_URL   网络图片请求地址
     * @param imageView 设置图片位置
     */
    public static void getBitmap(Context context, String PIC_URL, final ImageView imageView) {
        mQueue = Volley.newRequestQueue(context);
        ImageRequest imageRequest = new ImageRequest(
                PIC_URL,
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap response) {
                        imageView.setImageBitmap(response);
                    }

                },
                1000, 500, Bitmap.Config.RGB_565,
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        imageView.setImageResource(R.mipmap.ic_launcher);
                    }
                }
        );
        mQueue.add(imageRequest);
    }


}
